<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Bagi_pendamping extends CI_Controller {

	function __construct() {
        parent::__construct();
        $this->isLogin();			
		$this->load->model("bagi/pembagian_pendamping"); 
		$this->load->model("master/master_pegawai"); 
		$this->num_post=10;					
	}
	
	function isLogin(){
		$login=$this->session->userdata('isLogin');
		if(! isset($login)||$login != true){
			$this->session->set_flashdata('error_login', 'Untuk Mengakses Admin Anda Harus Login!');
			redirect('login');	
		}
	}
	
	function index($id,$offset = 0)
	{
		$data['main_view']='bagi/pendamping/read';
		$wali=$this->pembagian_pendamping->atur_kelas($id);
		$data['list']=$this->pembagian_pendamping->read($id);	
		$data['list_pegawai']=$this->pembagian_pendamping->pegawai($wali->id_mr_pegawai);
		$data['id_atur_kelas']=$this->pembagian_pendamping->atur_kelas($id);
		$this->load->view('index',$data);
		
	}	
	
	function add_exe()
	{	
		$id_atur_kelas=$this->input->post('id_atur_kelas');
		$id_mr_pegawai=$this->input->post('id_mr_pegawai');
		$dataInsert = array(
			'id_atur_kelas'=>$id_atur_kelas,
			'id_mr_pegawai'=>$id_mr_pegawai
		);
		$this->pembagian_pendamping->add($dataInsert);
		$back = htmlspecialchars($_SERVER['HTTP_REFERER']);
		redirect ($back);
	}
	
	function delete()
	{
		$id_bagi_pendamping = $this->security->xss_clean($this->uri->segment(3));
		$this->pembagian_pendamping->delete($id_bagi_pendamping);
		$back = htmlspecialchars($_SERVER['HTTP_REFERER']);
		redirect ($back);
	}	

}